﻿//------------------------------------------------------------------------------
// <copyright file="EntityGenerator.cs" company="CommerceServer.net, Inc">
//    (c) 2012 CommerceServer.net, Inc. and its affiliates. All rights reserved.
// </copyright>
// <summary></summary>
//------------------------------------------------------------------------------ 
namespace CommerceServerContrib.CodeGeneration
{
    using CommerceServerContrib.CodeGeneration.ConfigurationHelpers;
    using System.Collections.Generic;

    public class EntityGenerator 
    {
        private string targetConfigurationFilePath;
        private string channel = string.Empty;
        private string userLocale = "en-US";
        private string userUILocale = "en-US";
        
        public EntityGenerator(string targetConfigurationFilePath)
        {
            this.targetConfigurationFilePath = targetConfigurationFilePath;
        }

        public EntityGenerator(string targetConfigurationFilePath, string channel, string userLocale, string userUILocale)
        {
            this.targetConfigurationFilePath = targetConfigurationFilePath;
            this.channel = channel;
            this.userLocale = userLocale;
            this.userUILocale = userUILocale;
        }

        public List<ClassDefinition> GetClassDefinitions()
        {
            using (var config = new FullConfigurationSwapper(this.targetConfigurationFilePath))
            {
                var commerceMetadata = new CommerceServerMetadataProcessor(this.channel, this.userLocale, this.userUILocale);
                return commerceMetadata.ClassDefinitions();
            }
        }
    }
}
